/*
 * OwnerUtil.fx
 *
 * Created on 2009-09-08, 11:02:01
 */

package shmallarchitect.gui;

import javafx.scene.Group;

import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.transform.Translate;

import javafx.scene.control.Button;
import javafx.scene.control.TextBox;

import javafx.scene.control.ListView;
import javafx.scene.CustomNode;
import javafx.scene.Node;

/**
 * @author Administrator
 */


public var editowner_mode:Boolean = false;

var ownerid = bind BaseLayout.local_list[DisplayLocum.displayed].owner;



var display_owner: Group = Group {

content: [

        Text {x: 5 y: 0;
              content: bind "Owner Name: {BaseLayout.owner_list[ownerid].getName()}"
              font: Font.font("Verdana", 10);
              fill: Color.web("#dbdbdb")
             },

        Text {x: 5 y: 20;
              content: bind "Owner Surname: {BaseLayout.owner_list[ownerid].getSurname()}"
              font: Font.font("Verdana", 10);
              fill: Color.web("#dbdbdb")
             },

        Text {x: 5 y: 40;
              content: bind "Owner Corporation: {BaseLayout.owner_list[ownerid].getCorporation()}"
              font: Font.font("Verdana", 10);
              fill: Color.web("#dbdbdb")
             },

        Text {x: 5 y: 60;
              content: bind "Owner Phone: {BaseLayout.owner_list[ownerid].getPhone()}"
              font: Font.font("Verdana", 10);
              fill: Color.web("#dbdbdb")
             },

        Text {x: 5 y: 80;
              content: bind "Owner email: {BaseLayout.owner_list[ownerid].getEmail()}"
              font: Font.font("Verdana", 10);
              fill: Color.web("#dbdbdb")
             },

]

                 transforms: [ Translate {x: 0 y: 0 }]
}

var owners_listbox:ListView = ListView {
              items: bind for(entry in BaseLayout.owner_list) {entry.getName();
                                                               }
              height: bind 22*sizeof(BaseLayout.owner_list)
              width: 200

transforms: [ Translate {x: 500, y: 60 } ]
}

var selected = bind owners_listbox.selectedIndex;

var addOwner: Button = Button {
        text: "Add this owner to the Gallery"
        action: function() {

                    insert new shmallarchitect.java.Owner(namebox.text, surnamebox.text,
                    corpbox.text, phonebox.text, emailbox.text) into BaseLayout.owner_list;
}

        transforms: [ Translate {x: 40, y: 560 } ]
}




var namebox = TextBox {

        text: "";
        columns: 20

transforms: [ Translate {x: 0, y: 30 } ]

}

var surnamebox = TextBox {

        text: "";
        columns: 40

transforms: [ Translate {x: 0, y: 70 } ]

}

var corpbox = TextBox {

        text: "";
        columns: 20

transforms: [ Translate {x: 0, y: 110 } ]

}

var phonebox = TextBox {

        text: "";
        columns: 20

transforms: [ Translate {x: 0, y: 150 } ]

}

var emailbox = TextBox {

        text: "";
        columns: 20

transforms: [ Translate {x: 0, y: 190 } ]

}

var labels: Group = Group {

content: [

        Text {x: 5 y: -2;
              content: "Owner Name:"
              font: Font.font("Verdana", 12);
              fill: Color.web("#ffffff")
             },

        Text {x: 5 y: -2+40;
              content: "Owner Surname:"
              font: Font.font("Verdana", 12);
              fill: Color.web("#ffffff")
             },

        Text {x: 5 y: -2+80;
              content: "Owner Company:"
              font: Font.font("Verdana", 12);
              fill: Color.web("#ffffff")
             },

        Text {x: 5 y: -2+120;
              content: "Owner Phone:"
              font: Font.font("Verdana", 12);
              fill: Color.web("#ffffff")
             },

        Text {x: 5 y: -2+160;
              content: "Owner e-mail:"
              font: Font.font("Verdana", 12);
              fill: Color.web("#ffffff")
             },


]

transforms: [ Translate {x: 0, y: 30 } ]
}



public function displayOwner (x_:Integer, y_:Integer) {

        return Group {
                         content: [display_owner, ]

                 visible: bind DisplayLocum.view_mode;
                 transforms: [ Translate {x: x_, y: y_ } ]
                 };

        }


public class editOwner extends CustomNode {

                public override function create(): Node {

                return Group {
                        content: [ addOwner, labels, namebox, surnamebox,
                        corpbox, phonebox, emailbox, owners_listbox,    ]

                      visible: bind editowner_mode;
                      transforms: [ Translate {x: 20, y: 30 } ]
                        };
                }
        }


/*public function editOwner() {

                return Group {
                        content: [ edit_owner, owners_listbox,  ]

                      visible: bind BaseLayout.editowner_mode;
                };
        } */



